package com.api.syh56.shengyunhui.controller.admin;

import com.api.syh56.shengyunhui.common.CommonPage;
import com.api.syh56.shengyunhui.common.CommonResult;
import com.api.syh56.shengyunhui.entity.DedicatedLines;
import com.api.syh56.shengyunhui.entity.dto.DedicatedLinesDto;
import com.api.syh56.shengyunhui.service.AdminDedicatedLinesService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 专线管理
 */
@RestController
@RequestMapping("admin/dedicatedLines")
public class AdminDedicatedLinesController {
    @Autowired
    private AdminDedicatedLinesService adminDedicatedLinesService;

    /**
     * 查询专线
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("select")
    public CommonResult<CommonPage<DedicatedLines>> select(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
                                           @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize){
        Page<DedicatedLines> select = adminDedicatedLinesService.select(pageNum, pageSize);
        return CommonResult.success(CommonPage.restPage(select));
    }

    /**
     * 添加专线
     * @param dedicatedLinesDto 专线详细
     * @return
     */
    @PostMapping("insert")
    public CommonResult<Object> insert(@RequestBody DedicatedLinesDto dedicatedLinesDto){
        adminDedicatedLinesService.insert(dedicatedLinesDto);
        return CommonResult.success(null);
    }

    /**
     * 修改专线
     * @param dedicatedLinesDto
     * @return
     */
    @PostMapping("update")
    public CommonResult<Object> updata(@RequestBody DedicatedLinesDto dedicatedLinesDto){
        adminDedicatedLinesService.update(dedicatedLinesDto);
        return CommonResult.success(null);
    }

    /**
     * 删除专线
     * @param dedicatedLines
     * @return
     */
    @PostMapping("delete")
    public CommonResult<Object> delete(@RequestBody DedicatedLines dedicatedLines){
        adminDedicatedLinesService.delete(dedicatedLines);
        return CommonResult.success(null);
    }

//    /**
//     * 分配司机给专线
//     */
//    @PostMapping("assign")
//    public CommonResult<Object> assign(@RequestBody DedicatedLines dedicatedLines){
//        adminDedicatedLinesService.assign(dedicatedLines);
//        return CommonResult.success(null);
//    }
}
